﻿using System.Threading.Tasks;
using Demo.Api.Data;
using Demo.Api.Models;
using Demo.Api.Services;
using Microsoft.AspNetCore.Mvc;

namespace Demo.Api.Controllers
{
    /// <summary>
    /// 事项实例所走过的线
    /// </summary>
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class ProcessLineController : ControllerBase
    {
        private readonly ProcessLineRepository _repository;

        public ProcessLineController(ProcessLineRepository repository)
        {
            _repository = repository;
        }

        /// <summary>
        /// 获取一个事项实例所有的走过的线
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Gets(long affairProcessId)
        {
            var result = await _repository.GetsAsync(affairProcessId);
            return Ok(result);
        }
        ///// <summary>
        ///// 添加一个走过的线
        ///// </summary>
        ///// <param name="model"></param>
        ///// <returns></returns>
        //[HttpPost]
        //public async Task<IActionResult> Add(ProcessLineDto model)
        //{
        //    var temp = model.To();
        //    temp.Id = IdWorker.NextId();
        //    if (await _repository.Add(temp))
        //        return Ok(temp.Id);
        //    else
        //    {
        //        return BadRequest("添加失败");
        //    }
        //}
        ///// <summary>
        ///// 删除
        ///// </summary>
        ///// <param name="id"></param>
        ///// <returns></returns>
        //[HttpDelete]
        //public async Task<IActionResult> Delete(long id)
        //{
        //    var result = await _repository.Delete(id);
        //    return Ok(result);
        //}
    }
}